<?php
$this->breadcrumbs = array(
    'Configuration',
    'Support Configuration' => array('list'),
    'List',
);

$this->menu = array();

//action create
if($this->action_create == 1) {
    array_push($this->menu, array('label' => 'Create Support Data', 'url' => array('create')));
}

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('site-support-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>
<div class="flat_area grid_16">
    <h2>List of Support Data</h2>
</div>
<div class="box grid_16 round_all">
    <h2 class="box_head grad_colour round_all">Advanced Search</h2>
    <a href="#" class="grabber">&nbsp;</a>
    <a href="#" class="toggle toggle_closed">&nbsp;</a>
    <div class="toggle_container" style="display:none;">
        <?php
        $this->renderPartial('_search', array(
            'model' => $model,
        ));
        ?>
    </div>
</div>
<!-- search-form -->
<?php
$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'site-support-grid',
    'dataProvider' => $model->search(),
    'filter' => $model,
    'columns' => array(
        array(
            'header' => 'No.',
            'value' => '$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)."."',
            'htmlOptions' => array('style' => 'text-align:center;'),
        ),
        array(
            'name' => 'support_support_category_id',
            'filter' => CHtml::listData(site_support_category::model()->findAll(), 'support_category_id', 'support_category_title'),
            'value' => 'site_support_category::Model()->FindByPk($data->support_support_category_id)->support_category_title',
        ),
        array(
            'name' => 'support_name',
            'value' => '$data->support_name',
        ),
        array(
            'name' => 'support_nick',
            'value' => '$data->support_nick',
        ),
        array(
            'name' => 'support_phone',
            'value' => '$data->support_phone',
        ),
        array(
            'name' => 'support_is_active',
            'type' => 'image',
            'value' => '($data->support_is_active == 1 ? Yii::app()->request->baseUrl . "/images/icon/b_ok.png" : Yii::app()->request->baseUrl . "/images/icon/b_notok.png")',
            'filter' => CHtml::activeDropDownList($model, 'support_is_active', array('' => '', '1' => 'Active', '0' => 'InActive')),
            'htmlOptions' => array('style' => 'text-align:center;'),
        ),
        array(
            'header' => 'Action',
            'class' => 'CButtonColumn',
            'template'=>'{view}{update}{delete}',
            'buttons' => array(
                'view' => array(
                    'imageUrl' => Yii::app()->request->baseUrl.'/images/icon/adm_detail_navy.png',
                ),
                'update' => array(
                    'imageUrl' => Yii::app()->request->baseUrl.'/images/icon/adm_edit_navy.png',
                    'visible' => $this->action_update,
                ),
                'delete' => array(
                    'imageUrl' => Yii::app()->request->baseUrl.'/images/icon/adm_delete_navy.png',
                    'visible' => $this->action_delete,
                ),
            ),
        ),
    ),
    'selectableRows' => 2,
    'selectionChanged' => 'userClicks',
    'pager' => array(
        'cssFile' => Yii::app()->params['backendUrl'] . '/css/style-pager.css',
        'header' => '',
        'firstPageLabel' => 'First',
        'prevPageLabel' => 'Previous',
        'nextPageLabel' => 'Next',
        'lastPageLabel' => 'Last',
    ),
    'cssFile' => Yii::app()->params['backendUrl'] . '/css/style-gridview.css',
    'loadingCssClass' => '',
));
?>
<script>
    var id = 0;
    function userClicks(target_id) {
        id = $.fn.yiiGridView.getSelection(target_id);
    }
</script>